package com.real8.plusplayground.client.menu;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class MenuViewer extends Composite implements MenuView {
	private static MenuViewImplUiBinder uiBinder = GWT
			.create(MenuViewImplUiBinder.class);

	interface MenuViewImplUiBinder extends UiBinder<Widget, MenuViewer> {
	}

	private Presenter presenter;

	public MenuViewer() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public void setPresenter(Presenter aPresenter) {
		this.presenter = aPresenter;
	}

	@UiHandler("activityButton")
	void onActivityButtonClicked(ClickEvent e) {
		if (presenter != null) {
			presenter.onActivityReadSelected();
		}
	}

	@UiHandler("personButton")
	void onPersonButtonClicked(ClickEvent e) {
		if (presenter != null) {
			presenter.onPersonReadSelected();
		}
	}

	@UiHandler("statisticsButton")
	void onStatisticsButtonClicked(ClickEvent e) {
		if (presenter != null) {
			presenter.onStatisticsSelected();
		}
	}

	@UiHandler("miscellaneousButton")
	void onMiscellaneousButtonClicked(ClickEvent e) {
		if (presenter != null) {
			presenter.onMiscellaneousSelected();
		}
	}
}
